﻿@using Newtouch.Common.Operator;

@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<form id="form1">
    <div style="padding: 20px 35px 0 2px;">
        <table class="form">
            <tr>
                <th class="formTitle">代码</th>
                <td class="formValue">
                    <input type="text" class="form-control" id="dl" name="dl" required/>
                </td>
                <th class="formTitle">大类</th>
                <td class="formValue formDdlSelectorTd">
                    <input type="text" class="form-control" id="dlmc" name="dlmc" onblur="GetChineseSpell()" required />
                </td>
            </tr>
            <tr>
                <th class="formTitle">拼音</th>
                <td class="formValue">
                    <input type="text" class="form-control" id="py" name="py" required/>
                </td>
                <th class="formTitle">有效</th>
                <td class="formValue">
                    <div class="ckbox">
                        <input id="zt" name="zt" type="checkbox" checked="checked"><label for="zt"></label>
                    </div>
                </td>
            </tr>
            <tr>
                <th class="formTitle">排序</th>
                <td class="formValue">
                    <input type="text" class="form-control" id="px" name="px" />
                </td>
                <th class="formTitle">建档人员</th>
                <td class="formValue">
                    <input class="form-control newtouch_Readonly" id="CreatorCode" name="CreatorCode" value=@OperatorProvider.GetCurrent().UserCode type="text" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">建档日期</th>
                <td class="formValue">
                    <input class="form-control newtouch_Readonly" id="CreateTime" name="CreateTime" value=@DateTime.Now.ToString("yyyy-MM-dd") type="text"/>
                </td>
            </tr>
        </table>
    </div>
</form>

<script>
    var keyValue = $.request("keyValue");
    $(function () {
        if (!!keyValue) {
            $.ajax({
                url: "/SystemManage/SysMRChargeClass/GetFormJson?r=" + Math.random(),
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                }
            });
        }
    })

    //拼音
    function GetChineseSpell()
    {
        var strText = $("#dlmc").val();
        $.ajax({
            url: "/SystemManage/SysMRChargeClass/GetSpell?r=" + Math.random(),
            data: { strText: strText },
            dataType: "text",
            async: true,
            success: function (data) {
                $("#py").val(data);
            }
        });
    }

    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        $.submitForm({
            url: "/SystemManage/SysMRChargeClass/SubmitForm?keyValue=" + keyValue,
            param: $("#form1").formSerialize(),
            success: function () {
                $.currentWindow().window.frames['iframeExpenseManage'].$("#gridList").resetSelection();
                $.currentWindow().window.frames['iframeExpenseManage'].$("#gridList").trigger("reloadGrid");
                $.loading(false);
            }
        })
    }
</script>
